package com.course.app.transformer;

import com.course.app.api.data.TaskVideoDTO;
import com.course.domain.model.TaskVideo;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Created by Justin on 2017/5/30.
 */
public class TaskVideoTransformer {

    public static Map<Integer, TaskVideoDTO> toVideoMap(List<TaskVideo> taskVideoList) {
        return taskVideoList.stream()
                .map(TaskVideoTransformer::toVideo)
                .collect(Collectors.toMap(TaskVideoDTO::getId, Function.identity()));
    }

    private static TaskVideoDTO toVideo(TaskVideo taskVideo) {
        TaskVideoDTO videoDTO = new TaskVideoDTO();
        videoDTO.setId(taskVideo.getId());
        videoDTO.setTitle(taskVideo.getTitle());
        videoDTO.setDetail(taskVideo.getDetail());
        videoDTO.setMediaLink(taskVideo.getVideoLink());
        videoDTO.setAlbumLink(taskVideo.getAlbumLink());
        videoDTO.setRepeatTimes(taskVideo.getTimes());
        return videoDTO;
    }
}
